package chapter1_7_interrupt;

/**
 * @author huayuhao
 * @date 2020/12/15 17:09
 */
public class Interrupt1Test {

    public static void main(String[] args) throws InterruptedException {

        Thread thread = new Thread(() ->{
            while(!Thread.currentThread().isInterrupted()){
                System.out.println(Thread.currentThread() + "do something");
            }
        });
        thread.start();

        Thread.sleep(1000);

        System.out.println("主线程将要中断thread线程");
        thread.interrupt();

        thread.join();
        System.out.println(" main over");

    }
}
